package com.levi.threadutils.controller;

import com.levi.threadutils.common.IndexData;
import com.levi.threadutils.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;
/**
 * @description:
 * @author: shentong
 * @create: 2022-01-04 15:44
 **/
@RestController
public class UserController {

    @Autowired
    private UserService userService;
//    多线程导入速度是单线程导入速度的两倍，
    @GetMapping("/importData")
    public void importData() throws Exception {
        userService.importData();
    }

    @GetMapping("/importsingle")
    public void importsingle(){
        userService.importsingle();
    }

    @GetMapping("/indexData")
    public Map<String, Object> getIndexData() {
        return IndexData.dataMap;
    }

    //    多线程导入,按照固定线程数量分任务
    @GetMapping("/importData1")
    public void importData1() throws Exception {
        userService.importData1();
    }

}
